package com.finder.im.server.friendship.controller;

import com.finder.im.common.ResponseVO;
import com.finder.im.server.friendship.model.req.AddFriendReq;
import com.finder.im.server.friendship.model.req.DeleteFriendReq;
import com.finder.im.server.friendship.model.req.ImportFriendShipReq;
import com.finder.im.server.friendship.model.req.UpdateFriendReq;
import com.finder.im.server.friendship.service.ImFriendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("v1/friendship")
public class ImFriendShipController {
    @Autowired
    ImFriendService imFriendService;

    @RequestMapping("/importFriendShip")
    public ResponseVO importFriendShip(@RequestBody @Validated ImportFriendShipReq req, @RequestParam("appId") Integer appId) {
        req.setAppId(appId);
        return imFriendService.importFriendShip(req);
    }

    @RequestMapping("/addFriend")
    public ResponseVO addFriend(@RequestBody @Validated AddFriendReq req, @RequestParam("appId") Integer appId) {
        req.setAppId(appId);
        return imFriendService.addFriend(req);
    }

    @RequestMapping("/updateFriend")
    public ResponseVO updateFriend(@RequestBody @Validated UpdateFriendReq req, @RequestParam("appId") Integer appId) {
        req.setAppId(appId);
        return imFriendService.updateFriend(req);
    }

    @RequestMapping("/deleteFriend")
    public ResponseVO deleteFriend(@RequestBody @Validated DeleteFriendReq req,@RequestParam("appId")Integer appId) {
        req.setAppId(appId);
        return imFriendService.deleteFriend(req);
    }

    @RequestMapping("/deleteAllFriend")
    public ResponseVO deleteAllFriend(@RequestBody @Validated DeleteFriendReq req,@RequestParam("appId")Integer appId) {
        req.setAppId(appId);
        return imFriendService.deleteFriend(req);
    }

}
